package com.lut.single;

/**
 * @author liuning
 * @ProjectName SingleModel
 * @time 2021/11/24 16:24
 */
//饿汉式单例(存在的问题，不管三七二十一，上来就创建实例。可能造成内存浪费)
public class Hungry {
    //可能会浪费空间
    private byte[] data1 = new byte[1024];
    private byte[] data2 = new byte[1024];
    private byte[] data3 = new byte[1024];
    private byte[] data4 = new byte[1024];

    //构造方法私有，保证只有一个实例
    private Hungry(){

    }
    private final static Hungry HUNGRY = new Hungry();

    public static Hungry getInstance(){
        return HUNGRY;
    }
}
